<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>

<body>
  <script>
    var arr = [2, 7, 11, 15, 20, 24]
    var target = 23
    function fn(arr) {
      var obj = {}
      for (let i = 0; i < arr.length; i++) {
        obj.a = i
        // console.log(i)
        for (let j = 0; j < arr.length; j++) {
          obj.b = j
          // console.log(i, j)
          // 判断 arr[i]里面的那个元素 + arr[j]里面的那个元素 = target
          if (arr[i] + arr[j] == target) {
            return true
          }
        }
      }
      return false
    }
    console.log(fn(arr));
  </script>
</body>

</html>